home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dvips / RCS / tex.lpro,v < prev    next >
Encoding:
Text File  |  1990-03-02  |  13.8 KB  |  439 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.2
  10. date     90.03.01.23.24.07;  author shirriff;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     90.03.01.12.46.55;  author shirriff;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @These are Fred's changes.
  27. @
  28. text
  29. @% The following defines procedures assumed and used by program "dvips"
  30. % and must be downloaded or sent as a header file for all TeX jobs.
  31. % Originated by Neal Holtz, Carleton University, Ottawa, Canada
  32. %      <holtz@@cascade.carleton.cdn>
  33. %      June, 1985
  34. %
  35. %   Hacked by tgr, July 1987, stripped down to bare essentials,
  36. %   plus a few new commands for speed.
  37. %
  38. %   Hacked by don, December 1989, to give characters top down and to
  39. %   remove other small nuisances; merged with tgr's compression scheme
  40. %
  41. % To convert this file into a downloaded file instead of a header
  42. % file, uncomment all of the lines beginning with %-%
  43. %
  44. %   To observe available VM, uncomment the following.
  45. %   (The first ten lines define a general 'printnumber' routine.)
  46. %
  47. % /VirginMtrx 6 array currentmatrix def
  48. % /dummystring 20 string def
  49. % /numberpos 36 def
  50. % /printnumber { gsave VirginMtrx setmatrix
  51. %   /Helvetica findfont 10 scalefont setfont
  52. %   36 numberpos moveto
  53. %   /numberpos numberpos 12 add def
  54. %   dummystring cvs show
  55. %   grestore
  56. %   } bind def
  57. % /showVM { vmstatus exch sub exch pop printnumber } def
  58. % /eop-aux { showVM } def
  59. %
  60. %-%0000000             % Server loop exit password
  61. %-%serverdict begin exitserver
  62. %-%  systemdict /statusdict known
  63. %-%  {statusdict begin 9 0 3 setsccinteractive /waittimeout 300 def end}
  64. %-% if
  65.  
  66. /TeXDict 200 dict def   % define a working dictionary
  67. TeXDict begin           % start using it.
  68.  
  69. /bdf { bind def } def
  70.  
  71. % The output of dvips assumes pixel units, Resolution/inch, with
  72. % increasing y coordinates corresponding to moving DOWNWARD.
  73. % The PostScript default is big point units (bp), 72/inch, with
  74. % increasing y coordinates corresponding to moving UP; the
  75. % following routines handle conversion to dvips conventions. 
  76.  
  77. % Let the PostScript origin be (xps,yps) in dvips coordinates.
  78. /@@rigin                 % -xps -yps @@rigin -   establishes dvips conventions
  79.   { 72 Resolution div dup neg scale
  80.     translate
  81.   } bdf
  82.  
  83. % Here we assume the PostScript origin is at the bottom left corner
  84. % and that the paper is 11 inches high;
  85. % the dvips origin is 1 inch from top left corner;
  86. % hence if Resolution=300, we have (xps,yps)=(-300,3000). 
  87. /@@letter                % setup for standard letter format
  88.   { Resolution dup -10 mul @@rigin } bdf
  89.  
  90. /@@landscape
  91.   { [ 0 1 -1 0 0 0 ] concat
  92.     Resolution dup @@rigin } bdf
  93.  
  94. /@@a4
  95.   { Resolution dup -10.6929133858 mul @@rigin } bdf
  96.  
  97. /@@legal
  98.   { Resolution dup -13 mul @@rigin } bdf
  99.  
  100. /@@manualfeed
  101.    { statusdict /manualfeed true put
  102.    } bdf
  103.  
  104.         % n @@copies -   set number of copies
  105. /@@copies
  106.    { /#copies exch def
  107.    } bdf
  108.  
  109. % Bitmap fonts are called fa, fb, ..., fz, f0, f1, ...; the maximum
  110. % supported by these macros is f999, but if you really go up that high
  111. % you need to increase the size of TeXDict.
  112. % The calling sequence for downloading font foo is
  113. %           /foo df chardef1 ... chardefn dfe
  114. % where each chardef is
  115. %           [<hexstring> wd ht xoff yoff dx] charno dc
  116.  
  117. /@@FontMatrix [1 0 0 -1 0 0] def
  118. /@@FontBBox [0 0 0 0] def
  119.  
  120. /dmystr (ZZf@@@@@@) def       % define a place to put the new name
  121. /newname {dmystr cvn} bdf  % make it easy to get that name
  122. /df       % id df -         -- initialize a new font dictionary
  123.   { /fontname exch def
  124.     dmystr 2 fontname cvx (@@@@@@@@) cvs putinterval  % put name in template
  125.     newname 7 dict def              % allocate new font dictionary
  126.     newname load begin
  127.         /FontType 3 def
  128.     /FontMatrix @@FontMatrix def
  129.     /FontBBox @@FontBBox def
  130.         /BitMaps 256 array def
  131.         /BuildChar {CharBuilder} def
  132.         /Encoding IdentityEncoding def
  133.         end
  134.     fontname { /foo setfont }       %  dummy macro to be filled in
  135.        2 array copy cvx def         %  have to allocate a new one
  136.     fontname load                   %  now we change it
  137.        0 dmystr 6 string copy       %  get a copy of the font name
  138.        cvn cvx put                  %  and stick it in the dummy macro
  139.   } bdf
  140.  
  141. /dfe { newname dup load definefont setfont } bdf
  142.  
  143. % the following is the only character builder we need.  it looks up the
  144. % char data in the BitMaps array, and paints the character if possible.
  145. % char data  -- a bitmap descriptor -- is an array of length 6, of
  146. %          which the various slots are:
  147.  
  148. /ch-image {ch-data 0 get} bdf   % the hex string image
  149. /ch-width {ch-data 1 get} bdf   % the number of pixels across
  150. /ch-height {ch-data 2 get} bdf  % the number of pixels tall
  151. /ch-xoff  {ch-data 3 get} bdf   % number of pixels to right of origin
  152. /ch-yoff  {ch-data 4 get} bdf   % number of pixels below origin
  153. /ch-dx  {ch-data 5 get} bdf   % number of pixels to next character
  154.  
  155. /CharBuilder    % fontdict ch Charbuilder -     -- image one character
  156.      {save 3 1 roll exch /BitMaps get exch get /ch-data exch def
  157.       ch-data null ne
  158.       {ch-dx 0 ch-xoff ch-yoff neg
  159.        ch-xoff ch-width add ch-height ch-yoff sub
  160.        setcachedevice
  161.        ch-width ch-height true
  162.        [1 0 0 -1 -.1 ch-xoff sub ch-height ch-yoff sub .1 add]
  163. % begin code for uncompressed fonts only
  164.        {ch-image} imagemask
  165.      }if
  166.      restore
  167.   } bdf
  168. % end code for uncompressed fonts only
  169. % % here's the alternate code for unpacking compressed fonts
  170. %      /id ch-image def                          % image data
  171. %      /rw ch-width 7 add 8 idiv string def      % row, initially zero
  172. %      /rc 0 def                                 % repeat count
  173. %      /gp 0 def                                 % image data pointer
  174. %      /cp 0 def                                 % column pointer
  175. %      { rc 0 ne { rc 1 sub /rc exch def rw } { G } ifelse } imagemask
  176. %    }if
  177. %    restore
  178. % } bdf
  179. % /G { { id gp get /gp gp 1 add def
  180. %   dup 18 mod exch 18 idiv pl exch get exec } loop } bdf
  181. % /adv { cp add /cp exch def } bdf
  182. % /chg { rw cp id gp 4 index getinterval putinterval
  183. %         dup gp add /gp exch def adv } bdf
  184. % /nd { /cp 0 def rw exit } bdf
  185. % /lsh { rw cp 2 copy get dup 0 eq { pop 1 } { dup 255 eq { pop 254 }
  186. %     { dup dup add 255 and exch 1 and or } ifelse } ifelse put 1 adv } bdf
  187. % /rsh { rw cp 2 copy get dup 0 eq { pop 128 } { dup 255 eq { pop 127 }
  188. %     { dup 2 idiv exch 128 and or } ifelse } ifelse put 1 adv } bdf
  189. % /clr { rw cp 2 index string putinterval adv } bdf
  190. % /set { rw cp fillstr 0 4 index getinterval putinterval adv } bdf
  191. % /fillstr 18 string 0 1 17 { 2 copy 255 put pop } for def
  192. % /pl [
  193. %    { adv 1 chg } bind
  194. %    { adv 1 chg nd } bind
  195. %    { 1 add chg } bind
  196. %    { 1 add chg nd } bind
  197. %    { adv lsh } bind
  198. %    { adv lsh nd } bind
  199. %    { adv rsh } bind
  200. %    { adv rsh nd } bind
  201. %    { 1 add adv } bind
  202. %    { /rc exch def nd } bind
  203. %    { 1 add set } bind
  204. %    { 1 add clr } bind
  205. %    { adv 2 chg } bind
  206. %    { adv 2 chg nd } bind
  207. %    { pop nd } bind ] def
  208. % % end of code for unpacking compressed fonts
  209.  
  210.                % in the following, the font-cacheing mechanism requires that
  211.                 % a name unique in the particular font be generated
  212.  
  213. /dc            % char-data ch dc -    -- define character bitmap in current font
  214.   { /ch-code exch def
  215.     /ch-data exch def
  216.     newname load /BitMaps get ch-code ch-data put
  217.   } bdf
  218.  
  219. /bop           % bop -              -- begin a brand new page
  220.   {
  221.     gsave /SaveImage save def
  222.     0 0 moveto
  223.   } bdf
  224.  
  225. /eop           % - eop -              -- end a page
  226.   { % eop-aux  % -- to observe VM usage
  227.     clear SaveImage restore
  228.     showpage grestore
  229.   } bdf
  230.  
  231. /@@start         % - @@start -            -- start everything
  232.   {
  233.     /Resolution exch def
  234.     /IdentityEncoding 256 array def
  235.     0 1 255 {IdentityEncoding exch 1 string dup 0 3 index put cvn put} for
  236.   } bdf
  237.  
  238. /p { show } bdf        %  the main character setting routine
  239.  
  240. /RuleMatrix [ 1 0 0 -1 -.1 -.1 ] def % things we need for rules
  241. /BlackDots 8 string def
  242. /v {                   % can't use ...fill; it makes rules too big
  243.    gsave
  244.       currentpoint translate
  245.       false RuleMatrix { BlackDots } imagemask
  246.    grestore
  247. } bdf
  248. /a { moveto } bdf    % absolute positioning
  249. /delta 0 def         % we need a variable to hold space moves
  250. %
  251. %   The next ten macros allow us to make horizontal motions that
  252. %   are within 4 of the previous horizontal motion with a single
  253. %   character.  These are typically used for spaces.
  254. %
  255. /tail { dup /delta exch def 0 rmoveto } bdf
  256. /b { exch show tail } bdf      % show and tail!
  257. /c { show delta 4 sub tail } bdf
  258. /d { show delta 3 sub tail } bdf
  259. /e { show delta 2 sub tail } bdf
  260. /f { show delta 1 sub tail } bdf
  261. /g { show delta 0 rmoveto } bdf
  262. /h { show delta 1 add tail } bdf
  263. /i { show delta 2 add tail } bdf
  264. /j { show delta 3 add tail } bdf
  265. /k { show delta 4 add tail } bdf
  266. %
  267. %   These next allow us to make small motions (-4..4) cheaply.
  268. %   Typically used for kerns.
  269. %
  270. /l { show -4 0 rmoveto } bdf
  271. /m { show -3 0 rmoveto } bdf
  272. /n { show -2 0 rmoveto } bdf
  273. /o { show -1 0 rmoveto } bdf
  274. /q { show 1 0 rmoveto } bdf
  275. /r { show 2 0 rmoveto } bdf
  276. /s { show 3 0 rmoveto } bdf
  277. /t { show 4 0 rmoveto } bdf
  278. %
  279. %   w is good for small horizontal positioning.  x is good for small
  280. %   vertical positioning.  And y is good for a print followed by a move.
  281. %
  282. /w { 0 rmoveto } bdf
  283. /x { 0 exch rmoveto } bdf
  284. /y { 3 2 roll show moveto } bdf
  285. %
  286. %   The bos and eos commands bracket sections of downloaded characters.
  287. %
  288. /bos { /section save def } bdf
  289. /eos { clear section restore } bdf
  290.  
  291. end  % revert to previous dictionary
  292.  
  293.  
  294. %   This file also has the stuff from Paul Koning to implement the
  295. %   LN03 \special commands.  This is used by "changebars.sty".  
  296. %
  297.  
  298.  
  299. % /Resolution 300 def        % internal units are pixels (300/inch)
  300. /Inch {Resolution mul} def    % converts inches to internal units
  301.  
  302. /ln03$defs 10 dict def
  303. ln03$defs begin
  304. /points 256 array def
  305. 0 1 255 { points exch [ 0 0 ] put } for
  306. /linebuf 100 string def
  307.  
  308. % string -- postfix
  309. % defines /varnum in current dictionary
  310. /getvarnum
  311. { token not {stop} if            % get token, quit if none left
  312.   exec /varnum exch def            % execute it, save result
  313. } def
  314.  
  315. % string -- postfix
  316. % defines /varnum in current dictionary.
  317. % if input is of the form num/num2, uses num if Pagenum is odd, num2 if
  318. % it is even
  319. /get2varnum
  320. { { ( ) anchorsearch
  321.     { pop pop }
  322.     {exit} ifelse } loop        % eliminate leading spaces
  323.   ( ) search { exch pop } { () exch } ifelse  % look for terminating space
  324.                     % stack is now: -- postfix token
  325.   (/) search                % num1/num2 form?
  326.   { Pagenum 1 and 0 eq            % even page number?
  327.     { pop pop }                % yes, use second entry
  328.     { exch pop exch pop }        % use first number
  329.     ifelse
  330.   } if                    % now we have just the number wanted
  331.   cvi /varnum exch def            % convert and save it
  332. } def
  333.  
  334. % string default -- result
  335. /getdimension
  336. { exch dup length 1 sub 0 1 3 -1 roll    % get length, prepare to scan string
  337.   { pop dup 0 1 getinterval        % get first char
  338.     ( ) eq                % is it a space?
  339.     { dup length 1 sub 1 exch getinterval % yes, drop first char
  340.     } { exit } ifelse
  341.   } for
  342.   dup length 0 eq            % nothing but spaces?
  343.   { pop }                % yes, exit with default
  344.   { exch pop                % no, get rid of default
  345.     dup dup length 2 sub 2 getinterval    % get last two characters
  346.     1                    % default multiplier is 1
  347.     [[1 Inch 72 div (pt)]        % point
  348.      [1 Inch (in)]            % inch
  349.      [1 Inch 6 div (pc)]        % pica
  350.      [1 Inch 2.54 div (cm)]        % centimeter
  351.      [1 Inch 25.4 div (mm)]]        % milimeter
  352.     { aload pop                % get multiplier and string
  353.       3 index eq            % compare with suffix
  354.       { exch pop exit }            % match, use this multiplier
  355.       { pop }                % no match, pop unused multiplier
  356.       ifelse
  357.     } forall
  358.     exch pop                % get rid of suffix
  359.     exch dup length 2 sub 0 exch getinterval % get all but last 2 chars
  360.     cvr mul                % convert to a number, and form result
  361.   } ifelse
  362. } def
  363. end
  364.  
  365. /ln03:defpoint
  366. { ln03$defs begin
  367.   { currentfile linebuf readline
  368.     not {stop} if            % quit if premature eof
  369.     getvarnum                % get variable number
  370.     (\() search                % look for (
  371.     not {stop} if            % quit if missing
  372.     pop pop                % keep only string to its right
  373.     (,) search                % find separator
  374.     not {stop} if            % quit if missing
  375.     currentpoint pop            % default is current x
  376.     getdimension /x exch def        % process it and save result
  377.     pop                    % pop the comma
  378.     (\)) search                % search for )
  379.     not {stop} if            % quit if missing
  380.     currentpoint exch pop        % default is current y
  381.     getdimension [ x 3 -1 roll ]    % form [x y] pair
  382.     points varnum 3 -1 roll put        % update the variable
  383.     pop pop                % pop two results from search
  384.   } stopped
  385.   { (?Error in \\special ln03:defpoint) print pstack flush stop
  386.   } if
  387.   end
  388. } def
  389.  
  390. /ln03:connect
  391. { ln03$defs begin
  392.   { currentfile linebuf readline
  393.     not {stop} if            % quit if premature eof
  394.     get2varnum                % get one of two variable numbers
  395.     /firstvarnum varnum def        % save that one
  396.     get2varnum                % get another variable number
  397.     2 getdimension            % get dimension, default to 2
  398.     gsave                % save current graphics state
  399.     setlinewidth newpath        % initialize the line
  400.     points firstvarnum get        % get first variable
  401.     aload pop moveto            % get (x,y) pair, move there
  402.     points varnum get            % get second variable
  403.     aload pop lineto            % add a line to there
  404.     stroke grestore            % ... and that's all
  405.   } stopped
  406.   { (?Error in \\special ln03:connect) print pstack flush stop
  407.   } if
  408.   end
  409. } def
  410.  
  411. /ln03:resetpoints
  412. { ln03$defs begin
  413.   { currentfile linebuf readline
  414.     not {stop} if            % quit if premature eof
  415.     /firstvarnum 1 def            % default to 1-n rather than n-m
  416.     getvarnum                % get variable number
  417.     dup token                % is there anything else?
  418.     { pop pop /firstvarnum varnum def    % yes, save first number
  419.       getvarnum                % get another variable number
  420.     }
  421.     { pop }                % no, toss copy of string
  422.     ifelse
  423.     firstvarnum 1 varnum { points exch [ 0 0 ] put } for
  424.   } stopped
  425.   { (?Error in \\special ln03:resetpoints) print pstack flush stop
  426.   } if
  427.   end
  428. } def
  429. @
  430.  
  431.  
  432. 1.1
  433. log
  434. @Initial revision
  435. @
  436. text
  437. @d264 137
  438. @
  439.